#####################################################################################
#
# Copyright (c) Microsoft Corporation. 
#
# This source code is subject to terms and conditions of the Microsoft Public
# License. A  copy of the license can be found in the License.html file at the
# root of this distribution. If  you cannot locate the  Microsoft Public
# License, please send an email to  dlr@microsoft.com. By using this source
# code in any fashion, you are agreeing to be bound by the terms of the 
import clr
import sys
import getpath
sys.path.insert(0,getpath.getpath())
clr.AddReferenceToFile("IronPython.dll")
clr.AddReferenceToFile("CS.dll")
clr.AddReferenceByPartialName("System.Windows.Forms")
import System
import System.Windows
import NCS
#System.Windows.Forms.MessageBox.Show("hello", "");    
def testSession():
    if globals().has_key('session'):
        f=open("out.txt","wb")
        f.write("begin")
        try:
            s=dir(session)
            l = session.CreateSQLQuery("select * from dochanel").AddEntity(NCS.doChanel).List()
            f.write("load")
            f.write(l.ToString()+"\n")
            for l1 in  l:
                f.write(l1.ToString()+"\n")
                f.write(l1.cname+"\n")
        except System.Exception,e:
            f.write(e.ToString())
        f.close()
    else:
        pass    
def testFrmMain():
    if globals().has_key('frmMain'):
        f1=open("out.txt","w")
        f1.write("begin")
        try:
            frmMain.Text="hello ironpython!"
        except System.Exception,e:
            f1.write(e.ToString())
        f1.close()
    else:
        pass
f1=open("log.txt","w")        
g=globals().copy()     
for g1 in g:
    f1.write(g1.ToString()+"\n");
f1.close()
#testFrmMain()
testSession()
    #MessageBox.Show("Please set 'session' variable'")
